# Maintainer: Ray Donnelly <mingwandroid@gmail.com>

pkgname=procps
pkgver=3.2.8
pkgrel=2
pkgdesc="System and process monitoring utilities"
arch=('i686' 'x86_64')
url="http://procps.sourceforge.net/"
license=('GPL2')
groups=('sys-utils')
depends=('msys2-runtime')
options=('!emptydirs' 'strip')
# procps-3.2.8-2.src.patch is by Cygwin's Corinna Vinschen.
source=(http://procps.sourceforge.net/$pkgname-$pkgver.tar.gz
        procps-3.2.8-2.src.patch)
md5sums=('9532714b6846013ca9898984ba4cd7e0'
          'ea5e7432ead01d3f28c782c100a3c9df')

prepare() {
  cd ${srcdir}/$pkgname-$pkgver

  patch -p2 -i ${srcdir}/procps-3.2.8-2.src.patch
}

build() {
  cd ${srcdir}/$pkgname-$pkgver
  make \
    CFLAGS+=" -I/usr/include/ncursesw" \
    CURSES=-lncursesw \
    CPPFLAGS+=" -I/usr/include/ncursesw"
}

package() {
  cd ${srcdir}/$pkgname-$pkgver
  make DESTDIR=${pkgdir} install

  # fix permissons
  find ${pkgdir}/ -type f \( -name "*.dll" -o -name "*.exe" \) | xargs chmod 0755

  mv -f ${pkgdir}/bin/* ${pkgdir}/usr/bin/
  rm -r ${pkgdir}/bin
  mv -f ${pkgdir}/sbin ${pkgdir}/usr/
}
